package com.ftg.learn.controller;

import com.ftg.learn.entity.sys.Role;
import com.ftg.learn.entity.sys.User;
import com.ftg.learn.service.IRoleService;
import com.ftg.learn.service.impl.RoleServiceImpl;
import com.ftg.learn.util.AbstractController;
import com.ftg.learn.util.ResultJson;
import com.ftg.learn.util.ServiceUtil;
import com.ftg.learn.vo.UserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 角色表，用来存储当前系统的角色 前端控制器
 * </p>
 *
 * @author kangjx
 * @since 2022-10-27
 */
@RequestMapping("/sys/role")
@RestController
@Api(tags = "角色管理")
public class RoleController extends AbstractController<RoleServiceImpl,Role> {

    //角色 ： 删除   删除 本表   用户角色中间表  角色资源中间表

    //为角色授权 :

    @Resource
    ServiceUtil serviceUtil;

    @ApiOperation("测试")
    @GetMapping("/demo")
    public ResultJson abc(@RequestParam("page") @ApiParam(value = "页码",defaultValue = "1") int page,
                          @RequestParam("limit") @ApiParam(value = "条目数",defaultValue = "10")int limit){
        String sql = "select * from sys_user";
        return serviceUtil.pageUtilForMap(sql,page,limit);
    }

    @ApiOperation("测试")
    @GetMapping("/demo1")
    public ResultJson abcT(@RequestParam("page") @ApiParam(value = "页码",defaultValue = "1") int page,
                          @RequestParam("limit") @ApiParam(value = "条目数",defaultValue = "10")int limit){



        String sql = "select id,u_account uaccount,u_password,is_deleted isDelete from sys_user";

        return serviceUtil.pageUtilForT(sql,page,limit,UserVo.class);
    }

}
